var Set = {
	init: function() {
		$("#name").text((CurrentUser.name||CurrentUser.username) + " ( " +  (CurrentUser.level?STULEVELTEXT[CurrentUser.level]:"门外汉") + " )");
		$("#phone").text(CurrentUser.phone);
		$("#photo").css("background-image", "url('"+ Core.id2url(CurrentUser) +"')");
	},
	editFiled: function(title) {
		SetLS("set_edit_filed", {title:title});
		OpenNewWin("set_edit");
	},
	edit: function(){
	    if (filed.title == "修改名称") {
	        if(!$("#cname").val()) {
	          return $alert("请输入您要修改的新名字！");  
	        }
	        var data = CurrentUser;
	        data.name = $("#cname").val();
	        $ajax({
	            url: "/user/upsert",
	            data: data,
	            success: function(res) {
	            	CurrentUser.name = data.name;
	            	SetLS("user", CurrentUser);
	            	PCall("tab3","$('#name').text('" + data.name + " ( " +  (CurrentUser.level?STULEVELTEXT[CurrentUser.level]:"门外汉") + " )" + "')");
	            	PCall("root","$('#name').text('" + data.name + " ( " +  (CurrentUser.level?STULEVELTEXT[CurrentUser.level]:"门外汉") + " )" + "')");
	                WinClose();
	            }
	        });

	    } else {
	    	var opwm = $("#oldpwd").val();
	        if(!opwm)
	        	return $alert("请输入旧密码！");
			if (!$("#pwd").val() || !$("#cfmPwd").val())
				return $alert("请填写完整");
			if ($("#pwd").val() != $("#cfmPwd").val()){
				$("#pwd").val("");
				$("#cfmPwd").val("");
				return $alert("两次输入的密码不同，请重新输入!");
			}
			var data = CurrentUser;
			data.oldPassword = opwm;
			data.password = $("#pwd").val();
			$ajax({
				url: "/user/updatePassword",
				data: data,
				success: function(res){
					$alert("密码修改成功！");
	                WinClose();
				}
			});
	    }
	},
	mphoto: function() {
		Upload.init(Core.API_VER + "/user/updatephoto?id="+CurrentUser._id, function(res) {

			CurrentUser.photo = res[0].result.url;
			SetLS("user", CurrentUser);
			var photo = Core.id2url(CurrentUser);
			$("#photo").css("background-image", "url('" + photo + "')");
			PCall("root","$('#photo').css('background-image','url(" + photo + ")')");
		});
	},
	lgnout: function() {
		ActionSheet("您确定要退出登录吗？", "取消", new Array("退出登录"), function() {
			SetLS("user", null);
			CurrentUser = "";
			//SetLS("never", null);
			//OpenNewWin("index");
			//uexWidgetOne.exit();
			PCall("root","Index.userInit();");
			WinClose();
		});

	}
}